<template>
  <FormView
    v-model="entity"
    :title="entity.id ? '修改厂商信息' : '新建厂商信息'"
    :toolbar-attrs="{ buttons: ['back', 'save', 'cancel'] }"
    :toolbar-listeners="{ save: persist }">
    <FormHolder ref="form" label-width="100px" :model="entity">
      <FormItemGroup block-title="基本信息">
        <FormInput v-model="entity.name" prop="name" label="厂商名称" max-length="255" :span="24" required />
        <FormInput v-model="entity.evaluateGrade" prop="evaluateGrade" label="评价结果" max-length="255" :span="24" />
        <FormTextarea v-model="entity.description" rows="5" prop="description" label="厂商描述" max-length="3000" />
        <FormInput
          v-model="entity.contactAddress"
          prop="contactAddress"
          :span="24"
          label="厂商地址"
          max-length="255"
          required />
        <FormInput v-model="entity.contactor" prop="contactor" label="联系人" max-length="32" required />
        <FormInput
          v-model="entity.contactTelephone"
          prop="contactTelephone"
          label="联系电话"
          max-length="11"
          required />
        <FormInput v-model="entity.contactFaxno" prop="contactFaxno" label="传真电话" max-length="32" />
        <FormInput v-model="entity.contactEmail" prop="contactEmail" label="电子邮件" max-length="64" />
        <FormInput v-model="entity.weburl" prop="weburl" label="厂商主页" :span="24" max-length="255" />
        <FormInput v-model="entity.contactZipcode" prop="contactZipcode" label="邮政编码" max-length="32" />
        <FormInput v-model="entity.bank" prop="bank" label="开户银行" max-length="64" />
        <FormInput v-model="entity.bankAccount" prop="bankAccount" label="开户帐号" max-length="32" />
        <FormInput v-model="entity.dutyParagraph" prop="dutyParagraph" label="税号" max-length="32" />
      </FormItemGroup>
      <FormItemGroup :gutter="0" block-title="附件信息">
        <UploadPage
          v-if="entity.unid"
          ref="UploadPage"
          style="padding: 0"
          :unique-code="entity.unid"
          model="space"
          classify="regional" />
      </FormItemGroup>
    </FormHolder>
  </FormView>
</template>

<script>
  import { addObj, putObj, getObj, createM } from '@/api/asset/fyassetsupplier'
  import form from '@/vue/mixin/form'

  export default {
    name: 'MsupplierForm',

    mixins: [form],
    data() {
      return {
        entity: {
          bank: '',
          bankAccount: '',
          contactAddress: '',
          contactEmail: '',
          contactFaxno: '',
          contactTelephone: '',
          contactZipcode: '',
          contactor: '',
          createBy: '',
          createId: 0,
          createTime: '',
          deptFullname: '',
          deptId: 0,
          description: '',
          dutyParagraph: '',
          evaluateGrade: '',
          id: '',
          name: '',
          type: '',
          unid: '',
          updateBy: '',
          updateTime: '',
          weburl: ''
        }
      }
    },
    created() {
      this.init()
    },
    methods: {
      create: createM,
      load: getObj,
      save: addObj,
      update: putObj,
      async init() {}
    }
  }
</script>
